Vue.filter("improvePrice",function(){
  return "￥"+value.toFixed(2)
})

    let app2 = new Vue({
      el:"#app2",
    })
    
    let app = new Vue({
      el:"#app",
      data:{
           books:[
            {
              id:1,
              name:"111",
              date:'2024/6',
              price:50,
              count:1
            },
            {
              id:2,
              name:"222",
              date:'2024/5',
              price:50,
              count:1
            },
            {
              id:3,
              name:"333",
              date:'2024/4',
              price:50,
              count:1
            },
            {
              id:4,
              name:"444",
              date:'2024/3',
              price:50,
              count:1
            }
           ]
       },
       methods:{
        increase(index){
          this.books[index].count++
        },
        decrease(index){
          this.books[index].count--
        },
        remove(index){
          this.books.splice(index,1)
        }
       },
       computed:{
        totalPrice(){
          let total = 0
          for(const item of this.books){
            total += item.price * item.count
          }
          return total
        }
       },
       filters:{
        price(value){
          return "￥"+value.toFixed(3)
        }
       }
     })
